package com.util;

import android.content.Context;
import android.util.Log;

import com.Constant;
import com.android.scj.tc.Connection;
import com.android.scj.tc.TerminalService;
import com.android.scj.tc.TcAppFolw;
import com.baseutils.SpfUtils;


/**
 * 延时线程类
 *
 * @author 刘亚东
 *
 */
public class DelayTimeThread implements Runnable {

	private TerminalService tService = TerminalService.getService();

	private Connection con = Connection.getConnection();

	public volatile boolean IsDelay = true;
	private static TcAppFolw equiCon ;

	public DelayTimeThread(Context context) {
		boolean	psamopen = (boolean) SpfUtils.get(context, Constant.Check_Psam, true);
 	equiCon =  new TcAppFolw(context,psamopen);
		IsDelay = true;
	}

	public void isDelay(boolean isDelay) {
		IsDelay = isDelay;
	}

	@Override
	public void run() {
		while (IsDelay) {
			try {
				// 确定统一了 1001目录 0700A40000021001，操作IC卡，防止OBU掉电
				if(equiCon.SendTransferChannel("01", "010700A40000021001")==""){
					Log.e("防掉电：","超时退出");
					isDelay(false);
				}
				//equiCon.SendGetRand();
//				String baowen = tService.sendAC("5", "20", "01",
//						"0700A40000021001");
////				con.send(baowen);
//				Log.e("发送穿插：", baowen);
//				con.sendDelayedDate(baowen);
//				con.receiveDelayedDate();

			} catch (Exception e) {

			}
		}
	}

}
